package com.neuedu.yyzx.controller;


import com.neuedu.yyzx.config.CommonResult;
import com.neuedu.yyzx.entity.UserCare;
import com.neuedu.yyzx.service.IUserCareService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 第7组....
 * @since 2021-05-14
 */
@RestController
@RequestMapping("//userCare")
public class UserCareController {
    @Autowired
    IUserCareService userCareService;

    @GetMapping("/list")
    CommonResult list(UserCare userCare) {
        return CommonResult.success(userCareService.list(userCare));
    }
    @PostMapping("/add")
    CommonResult add(UserCare userCare) {
        if(userCareService.add(userCare))
            return CommonResult.success("ok");
        else
            return CommonResult.failed("角色名已经存在");
    }
    @GetMapping("/getById")
    CommonResult getById(Integer id) {
        return CommonResult.success(userCareService.getById(id));
    }
    @PostMapping("/update")
    CommonResult update(UserCare userCare) {
        return CommonResult.success(userCareService.updateById(userCare));
    }


}
